package com.autumn.xa.a.demo;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * ClassName: Demo4
 * Description:
 * Author: Shen_Yue
 * Date: 2023/7/18 23:05
 * History:
 * <author>          <time>          <version>          <desc>
 * Shen_Yue    2023/7/18 23:05   @Version 1.0        描述
 */
public class Demo4 {
    private static class Person {
        String name;

        public Person(String name) {
            this.name = name;
        }

        @Override
        public String toString() {
            return "Person{" +
                    "name='" + name + '\'' +
                    '}';
        }
    }

    private static class SuperMan {
        String name;
        String age;

        public SuperMan(String name, String age) {
            this.name = name;
            this.age = age;
        }

        @Override
        public String toString() {
            return "SuperMan{" +
                    "name='" + name + '\'' +
                    ", age='" + age + '\'' +
                    '}';
        }
    }

    public static void main(String[] args) {
        List<Person> persons = new ArrayList<Person>() {{
            add(new Person("shen_yue"));
            add(new Person("ye_chrom"));
            add(new Person("kiana"));
            add(new Person("mei"));
        }};
        System.out.println("---->> before persons");
        persons.forEach(System.out::println);

//        List<SuperMan> newList = persons.stream().map(p -> {
//            return new SuperMan(p.name + p.name + "222" , "100");
//        }).collect(Collectors.toList());
//
//        System.out.println("---->> after map persons");
//        persons.forEach(System.out::println);
//        System.out.println("---->> after map newList");
//        newList.forEach(System.out::println);
        Stream<Person> peek = persons.stream().peek(p -> {
            new SuperMan(p.name + 222, "100");
        });

        Stream<Person> stream = persons.stream().map(p -> {
            System.out.println();
            return p;
        });
    }
}
